{extend name="index_base" /} {block name="seo"}
<title>找回密码 - {$site_config['site_title']} - {$site_config['seo_title']}</title>


<meta name="keywords" content="{$site_config['seo_keyword']}">
<meta name="description" content="{$site_config['seo_description']}"> {/block} {block name="body"}
<div class="layui-container fly-marginTop">
    <div class="fly-panel fly-panel-user" pad20>
        <div class="layui-tab layui-tab-brief" lay-filter="user">
            <ul class="layui-tab-title">
                <li class="layui-this">找回密码</li>
            </ul>
            <div class="layui-tab-item layui-show">
                <div class="layui-btn-container" style="margin: 10px 0;">
                    <a href="javascript:;" onclick="findtype(1)" id="emailBtn" class="layui-btn layui-btn-sm">通过邮箱找回</a>
                    <a href="javascript:;" onclick="findtype(2)" id="phoneBtn"
                       class="layui-btn layui-btn-sm  layui-btn-primary">通过手机找回</a>
                </div>
                <div class="layui-form layui-form-pane">
                    <form method="post">

                        <div class="layui-form-item" id="emailType">
                            <label for="L_email" class="layui-form-label">邮箱</label>
                            <div class="layui-input-inline">
                                <input type="text" id="L_email" name="email" required="" lay-verify="email"
                                       autocomplete="off" class="layui-input"/>
                            </div>
                        </div>
                        <div class="layui-form-item" id="phoneType" style="display: none">
                            <label for="L_phone" class="layui-form-label">手机</label>
                            <div class="layui-input-inline">
                                <input type="text" id="L_phone" name="phone" required="" lay-verify="phone"
                                       autocomplete="off" class="layui-input"/>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label for="L_vercode" class="layui-form-label">验证码</label>
                            <div class="layui-input-inline">
                                <input type="text" name="code" required lay-verify="required" placeholder="请填写验证码"
                                       autocomplete="off" class="layui-input">
                            </div>
                            <div class="" style="float: left;">
                                <img src="{:url('login/captcha')}"
                                     onclick="this.src='{:url('login/captcha')}?'+Math.random();" class="fly-imagecode"
                                     id="captcha" alt="captcha"/>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label for="L_vercode" class="layui-form-label">验证码</label>
                            <div class="layui-input-inline">
                                <input type="text" id="L_vercode" name="vercode" required="" lay-verify="required"
                                       placeholder="请输入手机验证码" autocomplete="off" class="layui-input"/>
                            </div>
                            <div class="layui-form-mid" style="padding: 0!important;">
                                <button type="button" class="layui-btn layui-btn-normal" data-reason="forgetpasswd"
                                        data-type="byemail" id="getvercode">获取验证码
                                </button>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label for="L_phone" class="layui-form-label">新密码</label>
                            <div class="layui-input-inline">
                                <input type="text" id="L_phone" name="phone" required="" lay-verify="phone"
                                       autocomplete="off" class="layui-input"/>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <button class="layui-btn" alert="1" lay-filter="*" lay-submit="">提交</button>
                        </div>
                    </form>
                </div>
            </div>
            <!--            <div class="layui-form layui-tab-content" id="LAY_ucm" style="padding: 20px 0;">-->
            <!--                <div class="layui-tab-item layui-show">-->
            <!--                    <div class="layui-form layui-form-pane">-->
            <!--                        <form method="post">-->
            <!--                            <div class="layui-form-item">-->
            <!--                                <label for="L_email" class="layui-form-label">邮箱</label>-->
            <!--                                <div class="layui-input-inline">-->
            <!--                                    <input type="text" id="L_email" name="usermail" required lay-verify="required|emails" autocomplete="off" class="layui-input">-->
            <!--                                </div>-->
            <!--                            </div>-->
            <!--                            {if condition="$forgetyzm eq 1"}-->
            <!--                            <div class="layui-form-item">-->
            <!--                                <label for="L_vercode" class="layui-form-label">验证码</label>-->
            <!--                                <div class="layui-input-inline">-->
            <!--                                    <input type="text" name="code" required lay-verify="required" placeholder="请填写验证码" autocomplete="off" class="layui-input">-->
            <!--                                </div>-->
            <!--                                <div class="" style="float: left;">-->
            <!--                                    <img src="{:url('login/captcha')}" onclick="this.src='{:url('login/captcha')}?'+Math.random();" style="float:left; cursor:pointer;" id="captcha" alt="captcha" />-->
            <!--                                </div>-->
            <!--                            </div>-->
            <!--                            {/if}-->
            <!--                            <div class="layui-form-item">-->
            <!--                                <button class="layui-btn" alert="1" lay-filter="forget" lay-submit>提交</button>-->
            <!--                            </div>-->
            <!--                        </form>-->
            <!--                    </div>-->


        </div>
    </div>
</div>
</div>
</div>
{/block} {block name="script"}
<script>
    layui.use('form', function () {
        var form = layui.form,
            jq = layui.jquery;

        form.verify({
            emails: function (value) {
                var res = !!value.match(/^[\w\+\-]+(\.[\w\+\-]+)*@[a-z\d\-]+(\.[a-z\d\-]+)*\.([a-z]{2,4})$/i);
                if (!res) {
                    return '邮箱格式不正确';
                }
            }

        });

        form.on('submit(forget)', function (data) {
            loading = layer.load(2, {
                shade: [0.2, '#000']
            });
            var param = data.field;

            jq.post('{:url("user/login/forget")}', param, function (data) {
                layer.close(loading);
                if (data.code == 1) {
                    layer.msg(data.msg, {
                        icon: 1,
                        time: 1000
                    }, function () {

                    });
                } else {

                    layer.msg(data.msg, {
                        icon: 2,
                        anim: 6,
                        time: 1000
                    });
                    jq('#captcha').attr('src', "{:url('login/captcha')}?" + Math.random());
                }
            });
            return false;
        });
        window.findtype = function (type) {
            if (type == 1) {
                jq('#phoneBtn').addClass('layui-btn-primary');
                jq('#emailBtn').removeClass('layui-btn-primary');
                jq('#emailType').show();
                jq('#phoneType').hide();
                jq('#getvercode').data('type', 'email')
            } else {
                jq('#phoneBtn').removeClass('layui-btn-primary');
                jq('#emailBtn').addClass('layui-btn-primary');
                jq('#emailType').hide();
                jq('#phoneType').show();
                jq('#getvercode').data('type', 'phone')
            }
        }
    })


</script>{/block}